
package edu.wpi.first.wpilibj.templates.commands;

import edu.wpi.first.wpilibj.templates.LogitechController;

/**
 *
 * @author bradmiller
 */
public class MoveWristWithStick extends CommandBase {
        
    /*
     * Global Variables
     */
    private double commandedValue;
    private boolean isFinished;
    
    public MoveWristWithStick() {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
        requires(intake);
    } // end

    // Called just before this Command runs the first time
    protected void initialize() {

    } // end

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        
        commandedValue = oi.getCoDriverController().scale(oi.getCoDriverController().getLeftY(), 1);
        
        System.out.println("Commanded Value: " + commandedValue + " Pot Pos: " + intake.getPosition());
        
//        if (intake.getPosition() < 300 && commandedValue > 0) {
//                intake.manualDriveWrist(0);
//            
//        } else if (intake.getPosition() > 780 && commandedValue < 0) {
//            intake.manualDriveWrist(0);
//        } else {
//            intake.manualDriveWrist(-commandedValue);
//        }
        
//        if (intake.getPosition() < 780 && intake.getPosition() > 300) {
//            intake.manualDriveWrist(0);
//        } else if (intake.getPosition() > 780) {
//            
//            if (commandedValue > 0)
//                intake.manualDriveWrist(0);
//            else if (commandedValue < 0) 
//                intake.manualDriveWrist(0);
//            
//        } else if (intake.getPosition() < 300) {
//            
//            if (commandedValue > 0)
//                intake.manualDriveWrist(0);
//            else if (commandedValue < 0) 
//                intake.manualDriveWrist(0);
//        }
        
        intake.manualDriveWrist(-commandedValue);
        
    } // end

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return false;
    }// end

    // Called once after isFinished returns true
    protected void end() {
    }// end // end

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }// end
}// end MoveWristWithStick
